#!/bin/bash

TS_TOPDIR="${0%/*}/../.."
TS_DESC="read logins"

. "$TS_TOPDIR"/functions.sh
ts_init "$*"
ts_check_test_command "$TS_CMD_LSLOGINS"

#
# lslogin
#
$TS_CMD_LSLOGINS --version|grep "lastlog2" >/dev/null
if [ $? -ne 0 ]; then
    ts_skip "lastlog2 not supported"
fi

sqlite3 $TS_SELF/lastlog2.db < $TS_SELF/create_db.sql

# tests for lastlog2 environment
TZ=US/Pacific "$TS_CMD_LSLOGINS" --lastlog-file=/dev/null --lastlog2-file="${TS_SELF}/lastlog2.db" --wtmp-file=/dev/null --btmp-file=/dev/null --output USER,LAST-LOGIN,LAST-TTY,LAST-HOSTNAME --logins=root > "$TS_OUTPUT"

rm $TS_SELF/lastlog2.db
ts_finalize

